//
//  WKFRadarViewController.m
//  基本框架
//
//  Created by runone02 on 2018/8/21.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "WKFRadarViewController.h"
#import "WKFRadarView.h"
#import "RadarListController.h"
@interface WKFRadarViewController ()
/** 扫描view*/
@property (nonatomic, strong) WKFRadarView*  radarView;
@end

@implementation WKFRadarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadRadarView];
}

- (void)loadRadarView{
    float KMainWidth = [UIScreen mainScreen].bounds.size.width;
    float KMainHeight = [UIScreen mainScreen].bounds.size.height;
    [self.view setBackgroundColor:[UIColor whiteColor]];
    self.radarView = [[WKFRadarView alloc]initWithFrame:CGRectMake(0, (KMainHeight-KMainWidth)/2, KMainWidth, KMainWidth) andThumbnail:@"行"];
    [self.radarView.prButton addTarget:self action:@selector(removeView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.radarView];
    
    //添加图片
    [NSTimer scheduledTimerWithTimeInterval:1 target:self.radarView selector:@selector(addOrReplaceItem) userInfo:nil repeats:YES];
    
    double delayInSeconds = 10.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds *NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        //执行事件
        [self removeView];
    });
}

- (void)removeView{
    [self.radarView removeFromSuperview];
    RadarListController *radar = [[RadarListController alloc]init];
    [self.navigationController pushViewController:radar animated:YES];
}


- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.radarView removeFromSuperview];
}



@end
